package me.yiyou.meihua.data.xinghuo

import com.google.gson.annotations.SerializedName
import java.util.UUID

/**
 * 流式回复
 */
// 流式响应数据模型
data class XHFlowResponse(
    @SerializedName("code") val code: Int,
    @SerializedName("message") val message: String,
    @SerializedName("choices") val choices: List<FlowChoice>
) {
    data class FlowChoice(
        @SerializedName("delta") val delta: FlowDelta
    ) {
        data class FlowDelta(
            @SerializedName("role") val role: String?,
            @SerializedName("content") val content: String?,
            @SerializedName("reasoning_content") val reasoningContent: String?
        )

        // 获取有效内容：优先content，再reasoningContent
        fun getContent(): String? = delta.content ?: delta.reasoningContent
    }
}

sealed class ChatUiState {
    object Idle : ChatUiState()
    object Loading : ChatUiState()
    object Success : ChatUiState()
    data class Error(val message: String) : ChatUiState()
}

data class ChatMessage(
    val text: String,
    val isUser: Boolean,
    val id: String = UUID.randomUUID().toString()
)